#include<stdio.h>  
#include<unistd.h>  
#include<stdlib.h>  
#include<sys/wait.h>  
#include<signal.h>  
#include<sys/mman.h>  
  
int ga = 1;  
int main()  
{  
    int a = 10;  
    int *pa = malloc(sizeof(int));  
    *pa = 100;  
      
    int *ma = mmap(0,4,PROT_READ|PROT_WRITE,  
            MAP_ANONYMOUS|MAP_SHARED/*MAP_PRIVATE*/,0,0);  
    *ma = 1000;  
      
    int *spa = sbrk(4);  
    *spa = 10000;  
      
    if(fork())  
    {  
        printf("parent:ga = %d\n",ga);  
        printf("parent:a = %d\n",a);  
        printf("parent:*pa = %d\n",*pa);  
        printf("parent:*ma = %d\n",*ma);  
        printf("parent:*spa = %d\n",*spa);  
        a = 7;  
        ga = 77;  
        *pa = 777;  
        *ma = 7777;  
        *spa = 77777;  
    }  
    else  
    {  
        sleep(5);  
        printf("\nchild:ga = %d\n",ga);  
        printf("child:a = %d\n",a);  
        printf("child:*pa = %d\n",*pa);  
        printf("child:*ma = %d\n",*ma);  
        printf("child:*spa = %d\n",*spa);  
    }  
    return 0;  
}  

